// /////////////////////////////////////////////////////////////////////////////
//
// Name:            RGBPanel.cpp
// Author:          Michael Bartsch
//
// Desc :           This file contains the CRGBPanel class. This panel
//                  displays the colour analysis of one of the three main
//                  colours.
//
// License:         Copyright (C) 2008-2009 Michael Bartsch
//
//                  This program is free software: you can redistribute it
//                  and/or modify it under the terms of the GNU General Public
//                  License as published by the Free Software Foundation,
//                  either version 3 of the License, or (at your option) any
//                  later version.
//
//                  This program is distributed in the hope that it will be
//                  useful, but WITHOUT ANY WARRANTY; without even the implied
//                  warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
//                  PURPOSE. See the GNU General Public License for more
//                  details.
//
//                  You should have received a copy of the GNU General Public
//                  License along with this program. If not, see
//                  <http://www.gnu.org/licenses/>.
//
// /////////////////////////////////////////////////////////////////////////////

// Include required header file(s).
#include "RGBPanel.h"


// CRGBPanel Events. - [ BEGIN ]
BEGIN_EVENT_TABLE(CRGBPanel, wxPanel)
   EVT_PAINT(CRGBPanel::onPaint)
END_EVENT_TABLE()
// CRGBPanel Events. - [ END ]


// CRGBPanel.
// Constructor.
CRGBPanel::CRGBPanel(wxWindow *parent, char panelType)
: wxPanel(parent, wxID_ANY, wxDefaultPosition, wxSize(256, 256))
{
    pColourAnalyser = CColourAnalyser::Instance();
    panelColour = panelType;
}

// Event Functions. - [ BEGIN ]
void CRGBPanel::onPaint(wxPaintEvent &event)
{
    // Here we're going to create the paint DC.
    wxBufferedPaintDC *PanelDC = new wxBufferedPaintDC(this);

    wxString text;

    wxFont *font = new wxFont(8, wxFONTFAMILY_TELETYPE, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_LIGHT);
    PanelDC->SetFont(*font);
    delete font;

    // Paint on the DC.
    switch(panelColour)
    {
       case RGBPanel_R:   // Red

          if(pColourAnalyser->getHistogramR() != NULL)
            PanelDC->DrawBitmap(*pColourAnalyser->getHistogramR(), 0, 0, false);

          text.Printf("%d", pColourAnalyser->getBiggestR());
          PanelDC->DrawText(text, 200, 10);
          break;

       case RGBPanel_G:   // Green

          if(pColourAnalyser->getHistogramG() != NULL)
            PanelDC->DrawBitmap(*pColourAnalyser->getHistogramG(), 0, 0, false);

          text.Printf("%d", pColourAnalyser->getBiggestG());
          PanelDC->DrawText(text, 200, 10);
          break;

       case RGBPanel_B:   // Blue

          if(pColourAnalyser->getHistogramB() != NULL)
            PanelDC->DrawBitmap(*pColourAnalyser->getHistogramB(), 0, 0, false);

          text.Printf("%d", pColourAnalyser->getBiggestB());
          PanelDC->DrawText(text, 200, 10);
          break;
    }

    // Tidy code up.
    delete PanelDC;
}
// Event Functions. - [ END ]

// End of File
